$(document).ready(function () {

    //头部
    //搜索框
    $(".search-box").focus(function(){
        $(".threea").hide();
        $(".search").addClass("search-hover");
    });
    $(document).click(function (e) {
        var container = $(".navinner2");
        threea = $(".threea");
        if (!container.is(e.target) && container.has(e.target).length === 0) {
         threea.show();
            $(".search").removeClass("search-hover");
        }
    });
    //搜索按钮
    $(".search").hover(function () {
        $(this).toggleClass("search-hover");
    });
    //鼠标滑过banner部分
    $(".banner-left").hover(function () {
        $("#dropdown").toggle();
    });

    $("#panel a").each(function (index) {
        $(this).hover(function () {
            var n = index - 1;
            if (n >= 0) {
                var li = $("#dropdown li");
                li.eq(n).css("background", "#F7F7F7");
                li.eq(n).siblings().css("background", "#fff");
                li.eq(n).find("span").css("visibility", "visible");
                li.eq(n).siblings().find("span").css("visibility", "hidden");
            } else {
                return;
            }

        })
    });
    $("#dropdown li").each(function () {
        $(this).hover(function () {
            var t = $(this);
            t.css("background", "#F7F7F7");
            t.siblings().css("background", "#fff");
            t.find("span").css("visibility", "visible");
            t.siblings().find("span").css("visibility", "hidden");
        })
    });

    //鼠标离开第一个和最后一个时
    $(".towlesson").mouseleave(function () {
        $(".lesson-lib").css("background", "#fff");
        $(".lesson-lib").find("span").css("visibility", "hidden");
    });

    $(".school").mouseleave(function () {
        $(".Recruitment-lib").css("background", "#fff");
        $(".Recruitment-lib").find("span").css("visibility", "hidden");
    });

    // main1部分
    // main1左部分
    $(".main1-left li").hover(function () {
        $(this).toggleClass("main1-menu");
        $(this).find(".dl-wrap").toggle();
        $(this).children("a").toggleClass("togreen");
    });

    // main1-middlle上部分
    //控制图片两边的按钮
    $(".carousel1").hover(function () {
        $(this).find('.swiper-button-prev,.swiper-button-next').fadeToggle();
    });
    var swiper = new Swiper('.carousel1 .swiper-container', {
        pagination: '.carousel1 .swiper-pagination',
        nextButton: '.carousel1 .swiper-button-next',
        prevButton: '.carousel1 .swiper-button-prev',
        paginationClickable: true,
        spaceBetween: 30,
        centeredSlides: true,
        autoplay: 2500,
        loop:true,
        autoplayDisableOnInteraction: false

    });

    // main1-middlle下部分
    //控制两个箭头按钮
    $(".carousel2").hover(function () {
        $(this).find('.swiper-button-prev,.swiper-button-next').fadeToggle();
    });
    $(".carousel2").find('.swiper-button-prev').mouseenter(function () {
        $(this).css("background-position", "0 -40px");
    }).mouseleave(function () {
        $(this).css("background-position", "0 0");
    });
    $(".carousel2").find('.swiper-button-next').mouseenter(function () {
        $(this).css("background-position", "-24px -40px");
    }).mouseleave(function () {
        $(this).css("background-position", "-24px 0");
    });

    var swiper = new Swiper('.carousel2 .swiper-container', {
        pagination: '.carousel2 .swiper-pagination',
        nextButton: '.carousel2 .swiper-button-next',
        prevButton: '.carousel2 .swiper-button-prev',
        slidesPerView: 3,
        paginationClickable: true,
        spaceBetween: 30,
        loop: true
    });

    //main1-right3
    //外层4个按钮的变更
    $(".right3-top a").each(function (index) {
        $(this).mouseenter(function () {
            $("#right3inner").hide();
            $(".right3inner2").show();
            $(".ul-list").show();
            $(".ul-list li").eq(index).addClass("jschange");
            $(".ul-list li").eq(index).siblings().removeClass("jschange");
            $("#toggleBottom").children("div").eq(index).show();
            $("#toggleBottom").children("div").eq(index).siblings().hide();
        })
    });

    //内层4个按钮的变更
    $(".ul-list li").each(function (index) {
        $(this).mouseenter(function () {
            $(this).addClass("jschange");
            $(this).siblings().removeClass("jschange");
            $("#toggleBottom").children("div").eq(index).show();
            $("#toggleBottom").children("div").eq(index).siblings().hide();
        })
    });

    $(".right3inner2").mouseleave(function () {
        $(this).hide();
        $("#right3inner").show();
    });

    // mian2部分
    //鼠标滑过
    $(".menu-text li").each(function (index) {
        $(this).mouseenter(function () {
            $(".greenborder").removeClass("greenborder");
            $(this).addClass("greenborder");
            $(".firgreen").removeClass("firgreen");
            $(this).find("span").addClass("firgreen");
            $(".default2").removeClass("default2");
            $(".menu-image").children("div").eq(index).addClass("default2");
        })
    });

    $(".main2inner li").hover(function () {
        $(this).find(".inner1a img").fadeToggle();
        $(this).find(".hidediv div").slideToggle();
        $(this).find(".person").toggle();
        $(this).find(".grade2").toggle();
        $(this).find(".inner1a div").toggleClass("player-wrap");
    });

    // 职业路径图
    $(".list-img a").hover(function () {
        $(this).toggleClass("proa-toggle");
        $(this).find(".study").toggleClass("std-tog");
        $(this).find(".wait").toggleClass("wait-tog");
    });

    // 精品系列课程
    $(".pro-content li").hover(function () {
        $(this).find(".appearance").fadeToggle(300);
    });

    //wiki部分
    $(".imgbox").hover(function () {
        $(this).find("i").toggle();
    });
    // 战略合作企业
    $("#businer").hover(function () {
        $(this).find(".swiper-button-next,.swiper-button-prev").fadeToggle();
    });
    var swiper = new Swiper("#businer .swiper-container", {
        pagination: "#businer .swiper-pagination",
        nextButton: "#businer .swiper-button-next",
        prevButton: "#businer .swiper-button-prev",
        slidesPerView: 6,
        paginationClickable: true,
        spaceBetween: 30,
        loop: true
    });

    // 合作院校
    $(".academy").hover(function () {
        $(this).find(".swiper-button-next,.swiper-button-prev").fadeToggle();
    });

    var swiper = new Swiper(".academy .swiper-container", {
        pagination: ".academy .swiper-pagination",
        nextButton: ".academy .swiper-button-next",
        prevButton: ".academy .swiper-button-prev",
        slidesPerView: 7,
        paginationClickable: true,
        spaceBetween: 30,
        loop: true
    });


    // 媒体报道
    $(".media").hover(function () {
        $(this).find(".swiper-button-next,.swiper-button-prev").fadeToggle();
    });
    var swiper = new Swiper(".media .swiper-container", {
        pagination: ".media .swiper-pagination",
        nextButton: ".media .swiper-button-next",
        prevButton: ".media .swiper-button-prev",
        slidesPerView: 6,
        paginationClickable: true,
        spaceBetween: 30,
        loop: true
    });

    //footer底部
    $(".WeChat").hover(function () {
        $(".WeChat-img").toggle();
        $(this).css("background-position", "-22px -121px");
    }).mouseleave(function () {
        $(this).css("background-position", "-22px -81px")
    });

    $(".Microblog").mouseenter(function () {
        $(this).css("background-position", "-23px -40px")
    }).mouseleave(function () {
        $(this).css("background-position", "-23px 0")
    });

    $(".Post-Bar").mouseenter(function () {
        $(this).css("background-position", "-144px -40px")
    }).mouseleave(function () {
        $(this).css("background-position", "-144px 0")
    });

    var timer;
    $(".returnTop").click(function () {
        timer = setInterval(function () {
            var topHeight = $('body')[0].scrollTop;
            everyHeight = topHeight / 5;
            $('body')[0].scrollTop = topHeight - everyHeight;
            if (topHeight == 0) {
                clearInterval(timer);
            }
        }, 30)
    });

    $(window).on("scroll", function () {
        var lookHeight = $(window).height();
        var scrollHeight = $('body')[0].scrollTop;
        if (scrollHeight >= lookHeight) {
            $(".returnTop").css("display", "block");
        } else {
            $(".returnTop").css("display", "none");
        }
    })

});
